package com.gxa.controller;

import com.gxa.common.base.RespResult;
import com.gxa.domain.dto.MaterialDTO;
import com.gxa.domain.dto.StockDTO;
import com.gxa.domain.entity.Material;
import com.gxa.domain.entity.Stock;
import com.gxa.domain.vo.MaterialVO;
import com.gxa.domain.vo.StockVO;
import com.gxa.service.StockService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * User: gxb
 * Date: 2024/07/18  14:48
 * Description:
 * Version: V1.0
 */
@Api(tags = "库存管理-库存管理")
@RestController
@RequestMapping("/logistics/stock")
@Slf4j
public class StockController {
    @Autowired
    private StockService stockService;
    @ApiOperation("查询库存列表")
    @GetMapping("/list")
    public RespResult list() {
        //1.查询所有库存
        List<StockVO> stockVO = stockService.findStockAll();
        //2.返回给前端
        return RespResult.success(stockVO);
    }
    @ApiOperation("条件查询")
    @PostMapping("/list")
    public RespResult list(@RequestBody StockDTO stockDTO) {
        //1.查询页面数据
        List<Stock> stockList = stockService.findStockByWhere(stockDTO);
        //2.返回给前端
        return RespResult.success(stockList);
    }
}
